package com.site.service.impl;

import com.site.dao.ReserveTypeDao;
import com.site.dao.impl.ReserveTypeDaoImpl;
import com.site.pojo.ReserveType;
import com.site.service.ReserveTypeService;
import com.site.vo.ReserveTypeAndGoodsVO;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class ReserveTypeServiceImpl implements ReserveTypeService {
    private ReserveTypeDao reserveTypeDao = new ReserveTypeDaoImpl();

    @Override
    public List<ReserveType> selectAll() throws SQLException {
        return null;
    }

    @Override
    public ReserveType selectById(int id) throws SQLException {
        return null;
    }

    @Override
    public boolean addReserveType(ReserveType reserveType) {
        return false;
    }

    @Override
    public boolean addReserveType(Connection conn, ReserveType reserveType) {
        return false;
    }

    @Override
    public boolean delReserveTypeById(int id) {
        return false;
    }

    @Override
    public boolean delReserveTypeById(Connection conn, int id) {
        return false;
    }

    @Override
    public boolean delReserveTypeByState(int state) {
        return false;
    }

    @Override
    public boolean delReserveTypeByState(Connection conn, int state) {
        return false;
    }

    @Override
    public boolean updateReserveTypeByid(int id, ReserveType reserveType) {
        return false;
    }

    @Override
    public boolean updateReserveTypeByid(Connection conn, int id, ReserveType reserveType) {
        return false;
    }

    @Override
    public List<ReserveTypeAndGoodsVO> allVOCableSize() throws SQLException {
        return reserveTypeDao.allVOCableSize();
    }

    @Override
    public List<ReserveTypeAndGoodsVO> allVOCircuitBoardSize() throws SQLException {
        return reserveTypeDao.allVOCircuitBoardSize();
    }

    @Override
    public List<ReserveTypeAndGoodsVO> allVOElectricWireSize() throws SQLException {
        return reserveTypeDao.allVOElectricWireSize();
    }

    @Override
    public List<ReserveTypeAndGoodsVO> selectgetByrtidAndrid(int rtid, int rid) throws SQLException {
        List<ReserveTypeAndGoodsVO> all = new ArrayList<>();
        List<ReserveTypeAndGoodsVO> seletall = new ArrayList<>();
        List<ReserveTypeAndGoodsVO> list = reserveTypeDao.allVOCableSize();
        List<ReserveTypeAndGoodsVO> list1 = reserveTypeDao.allVOCircuitBoardSize();
        List<ReserveTypeAndGoodsVO> list2 = reserveTypeDao.allVOElectricWireSize();
        for (int i = 0; i < list.size(); i++) {
            all.add(list.get(i));
        }
        for (int i = 0; i < list1.size(); i++) {
            all.add(list1.get(i));
        }
        for (int i = 0; i < list2.size(); i++) {
            all.add(list2.get(i));
        }
        if (rid>0&&rtid>0){
            for (int i = 0; i < all.size(); i++) {
                if (all.get(i).getRid()==rid&&all.get(i).getRtid()==rtid){
                    seletall.add(all.get(i));
                }else {
                    continue;
                }
            }
        }else if (rid>0&&rtid<0){
            for (int i = 0; i < all.size(); i++) {
                if (all.get(i).getRid()==rid){
                    seletall.add(all.get(i));
                }else {
                    continue;
                }
            }
        }else if (rid<0&&rtid>0){
            for (int i = 0; i < all.size(); i++) {
                if (all.get(i).getRtid()==rtid){
                    seletall.add(all.get(i));
                }else {
                    continue;
                }
            }
        }else {
            return null;
        }
        return seletall;
    }
}
